<%@page import="hyl.core.db.*,hyl.core.info.Content,java.util.Map,hyl.core.MyFun,com.servlet.*"%>
<%@ page language="java" contentType="application/json;charset=UTF-8"
    pageEncoding="UTF-8"%><%
    		
    Content ct = new Content();
	String password = request.getParameter("password").trim();
	String newpassword1 = request.getParameter("newpassword1").trim();
	String newpassword2 = request.getParameter("newpassword2").trim();
	int state= MyFun.str2int(request.getParameter("state").trim());
	int  id= My.getSession(request, response).getUserId();
	System.out.print(id);
	//request, response
	if (!newpassword1.equals(newpassword2)) {
		ct.setCode(1,"wrong");
		out.print(ct.toJsonString());
		return;
	}
    String sql=null;
    if(state==1){
	sql = "select id from user where id=? and upass=?";
	Object[] params = { id, password };
	int 结果 =  MyFun.obj2Int( My.getDB1().querySingle(sql, params));
	if (结果==0) {
		ct.setCode(1,"error");
		out.print(ct.toJsonString());
		return;
	} else {
			sql = "update user set upass = ? where  id=?";
			Object[] params1 = { newpassword1, id };
			 My.getDB1().executeUpdate(sql, params1);
			 ct.setCode(1,"success");
			 out.print(ct.toJsonString());
			 return;	
	}
}else{
	 sql = "select id  from user_conf where id=? and t13=?";
	Object[] param = {id, password };
	int 结果 =  MyFun.obj2Int(My.getDB1().querySingle(sql, param));
	if (结果==0) {
		ct.setCode(1,"error");
		out.print(ct.toJsonString());
		return;
    } else {
			sql = "update user_conf set t13 = ? where id=?";
			Object[] param1 = { newpassword1, id };
			My.getDB1().executeUpdate(sql, param1);
			 ct.setCode(1,"success");
			 out.print(ct.toJsonString());
			 return;
	}
}
 
	
		
	
	
%>